import request from './request'

// 获取博客分类
export const getBlogCategory = () => {
  return request({
    url: '/api/blogtype'
  })
}

// 获取博客列表
export const getBlogList = (params: { page: number; limit: number; categoryid: number }) => {
  return request({
    url: '/api/blog',
    params
  })
}

export const getBlog = (id: string) => {
  return request.get(`/api/blog/${id}`)
}

/**
 * 提交评论
 */
export const postComment = (commentInfo: { nickname: string; content: string; blogId: string }) => {
  return request.post(`/api/comment`, commentInfo)
}

export const getComments = ({
  blogid,
  page = 1,
  limit = 10
}: {
  blogid: string
  page: number
  limit: number
}) => {
  return request.get('/api/comment', {
    params: {
      blogid,
      page,
      limit
    }
  })
}
